document.onreadystatechange = function() {    
    if (document.readyState == "complete") {
        
        username.value = System.Gadget.Settings.readString("username");
        password.value = System.Gadget.Settings.readString("password");
    }        
}
       
System.Gadget.onSettingsClosing = function(event) {
    if (event.closeAction == event.Action.commit) {
        
        System.Gadget.Settings.writeString("username", username.value);
        System.Gadget.Settings.writeString("password", password.value);
        
        event.cancel = false;
    }
}
